#include "SemanticNodeBlockAdvance.h"

/**
 *  @fn	SemanticNodeBlockAdvance::SemanticNodeBlockAdvance(const SyntaxTreeNode *advanceNodeParent,
 *  	SemanticNode *parent)
 * 
 *  @brief	Constructor.
 * 
 *  @author	Nikola Novak
 *  @date	6/25/2009
 * 
 *  @param	advanceNodeParent	If non-null, the advance node parent.
 *  @param	parent				If non-null, the parent.
 */
SemanticNodeBlockAdvance::SemanticNodeBlockAdvance(const SyntaxTreeNode *advanceNodeParent, SemanticNode *parent) : SemanticNode(parent), LabeledNode(advanceNodeParent->Nodes->GetData(0)) {
	deviation = (advanceNodeParent->Nodes->GetData(1)->Nodes->GetData(0)->Nodes->GetData(2)->Nodes->GetCount() > 0);
}
/**
 *  @fn	void SemanticNodeBlockAdvance::setTime(SemanticNodeExpression *time)
 * 
 *  @brief	Sets a time. 
 * 
 *  @author	Nikola Novak
 *  @date	6/25/2009
 * 
 *  @param	time	If non-null, the time.
 */
void SemanticNodeBlockAdvance::setTime(SemanticNodeExpression *time) {
	timeExpression = time;
}
/**
 *  @fn	void SemanticNodeBlockAdvance::setDeviation(SemanticNodeExpression *deviation)
 * 
 *  @brief	Sets a deviation. 
 * 
 *  @author	Nikola Novak
 *  @date	6/25/2009
 * 
 *  @param	deviation	If non-null, the deviation.
 */
void SemanticNodeBlockAdvance::setDeviation(SemanticNodeExpression *deviation) {
	deviationExpression = deviation;
}
/**
 *  @fn	bool SemanticNodeBlockAdvance::hasDeviation(void)
 * 
 *  @brief	Query if this object has deviation. 
 * 
 *  @author	Nikola Novak
 *  @date	6/25/2009
 * 
 *  @return	true if deviation, false if not.
 */
bool SemanticNodeBlockAdvance::hasDeviation(void) {
	return deviation;
}
/**
 *  @fn	std::string SemanticNodeBlockAdvance::toDebugString(int tab)
 * 
 *  @brief	Converts a tab to a debug string. 
 * 
 *  @author	Nikola Novak
 *  @date	6/25/2009
 * 
 *  @param	tab	The tab.
 * 
 *  @return	This object as a std::string.
 */
std::string SemanticNodeBlockAdvance::toDebugString(int tab) {
	std::ostringstream res;
	for (int i = 0; i < tab; i++)	res << DEBUG_STRING_RAZMAK;
	res << getLabelsDebugString() << ": advance " << std::endl;
	res << ((SemanticNode *)timeExpression)->toDebugString(tab + 1);
	for (int i = 0; i < tab; i++)	res << DEBUG_STRING_RAZMAK;
	if (!deviation) res << "+- -" << std::endl;
	else {
		res << "+-" << std::endl;
		res << ((SemanticNode *)deviationExpression)->toDebugString(tab + 1);
	}
	return res.str();
}
